using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QLThuHocPhi
{
    public partial class BaoCaoChiTiet : Form
    {
        public BaoCaoChiTiet()
        {
            InitializeComponent();
        }
        QLThuHocPhi.Database.DBTool dbt = new QLThuHocPhi.Database.DBTool();
        private void BaoCaoChiTiet_Load(object sender, EventArgs e)
        {
            Loadcombo();
            //QLHocPhiDataSet ds = new QLHocPhiDataSet();
            //QLHocPhiDataSetTableAdapters.v_TongThuTableAdapter da = new QLThuHocPhi.QLHocPhiDataSetTableAdapters.v_TongThuTableAdapter();
            //da.Fill(ds.v_TongThu);
            //ReportTongthu rp = new ReportTongthu();
            //rp.SetDataSource(ds);
            //crystalReportViewer1.ReportSource = rp;
        }
        private void LoadComboMon(int makhoa)
        {
            DataSet ds1 = new DataSet();
            ds1 = dbt.GetMonHoc(makhoa);
            this.cbmon.DataSource = ds1.Tables["Monhoc"];
            this.cbmon.DisplayMember = "TenMonHoc";
            this.cbmon.ValueMember = "Mamon";
        }
        private void Loadcombo() {
            DataSet ds2 = new DataSet();
            ds2 = dbt.LoadTenkhoa1();
            this.cbKhoa.DataSource = ds2.Tables["tenk1"];
            this.cbKhoa.DisplayMember = "Tenkhoa";
            this.cbKhoa.ValueMember = "Makhoa";
            DataSet ds3 = new DataSet();
            ds3 = dbt.LoadKhoahoc();
            this.cbKhoahoc.DataSource = ds3.Tables["tenkhoa"];
            this.cbKhoahoc.DisplayMember = "Khoahoc";
            this.cbKhoahoc.ValueMember = "Makhoahoc";
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string ngaybd = dateTimePicker1.Value.ToShortDateString() ;
            string ngaykt = dateTimePicker2.Value.ToShortDateString();
           // MessageBox.Show(ngaybd + ngaykt);
            string khoa = cbKhoa.Text;
            string khoahoc = cbKhoahoc.Text;
            string monhoc = cbmon.Text;
            //DataSet ds = new DataSet(); 
            // ds = dbt.v_tongthu(khoa, khoahoc,monhoc,ngaybd,ngaykt);
            DataSet ds = new DataSet();
           // QLHocPhiDataSetTableAdapters.v_TongThu1TableAdapter da = new QLThuHocPhi.QLHocPhiDataSetTableAdapters.v_TongThu1TableAdapter();
            ds = dbt.v_tongthu(khoa,khoahoc,monhoc,ngaybd,ngaykt);
           // da.Fill(ds.v_TongThu1);
            CrystalReport4 rp = new CrystalReport4();
            rp.SetDataSource(ds.Tables["v_Tongthu"]);
            crystalReportViewer1.ReportSource = rp;
        }

        private void cbKhoa_SelectedValueChanged(object sender, EventArgs e)
        {
            try
            {
                int a = int.Parse(cbKhoa.SelectedValue.ToString());
                LoadComboMon(a);
            }
            catch (Exception ex) { 
            
            }
        }
    }
}